package co.th.bjc.md.helper.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import co.th.bjc.md.dao.RpRating;
import co.th.bjc.md.helper.entries.HelperDatabse;

public class RpRatingHelper extends HelperDatabse{
	
	public RpRating findImpByImpCode(Integer rpCode) throws Exception{
		Connection con = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		RpRating rp = null;
		try {
			con = getConnection();
			stmt = con.prepareStatement(RP.FIND_BY_RP_CODE);
			stmt.setInt(1, rpCode); 
			
			rs = stmt.executeQuery();
			if (rs.next()){
				rp = new RpRating();
				rp.setRpCode(rs.getInt("rp_code"));
				rp.setRpName(rs.getString("rp_name"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			if (rs != null) rs.close();
			if (stmt != null) stmt.close();
			if (con != null) con.close();
		}
		return rp;
	}
}
